﻿/**
 * ...
 * @author Sergey Mamyan
 */

package tx.squirrel.neko.core.handler;

import mtwin.web.Handler;
import mtwin.web.Request;
import neko.Lib;

import tx.squirrel.neko.core.model.Installation;
import tx.squirrel.neko.core.model.Session;
import tx.squirrel.neko.core.model.Application;
import tx.squirrel.neko.core.model.User;

class FBAppHandler extends Handler < Void > {
	
	public var installation:Installation;
	public var session:Session;
	public var user:User;
	public var app:Application;
	
	public function new() {
		super();
		session = Session.session;
		app 	= Session.getApp();
		user 	= Session.getUser();
	}
	
	override public function execute( request:Request, ?pathLevel:Int ) {
		try {
			if (session.userId == null) {
				Lib.print('<fb:redirect url="http://www.facebook.com/login.php?v=1.0&api_key=' + app.apiKey +'"/>');
			}else{
				super.execute(request, pathLevel);
			}
		}catch (e:Dynamic) {
			trace(e);
		}
	}
}